/**
 * 
 */
package com.aceitunaproject.server.terrain;

import java.util.LinkedList;
import java.util.List;

import com.aceitunaproject.server.combat.CombatEffects;
import com.aceitunaproject.server.equipment.Equipment;
import com.aceitunaproject.server.installation.InstallationType;
import com.aceitunaproject.server.materialgoods.GoodProduction;

/**
 * Default Implementation of Terrain Type
 * 
 * 
 * @author Federico Bergstein
 * 
 */
public class TerrainTypeImpl implements TerrainType {

	private List<InstallationType> allowedInstallationTypes = new LinkedList<InstallationType>();
	private String defaultName = "";
	private List<GoodProduction> resources = new LinkedList<GoodProduction>();
	private List<InstallationType> disAllowedInstallationTypes = new LinkedList<InstallationType>();
	private List<Equipment> settlementEquipmentNeeded;
	private boolean allowsSettlements;

	/**
	 * Class constructor
	 */
	public TerrainTypeImpl(String defaultName, List<GoodProduction> resources,
			List<InstallationType> allowedInstallationTypes,
			List<InstallationType> disAllowedInstallationTypes,
			List<Equipment> settlementEquipmentNeeded, boolean allowsSettlements

	) {
		if (allowedInstallationTypes != null)
			this.allowedInstallationTypes = allowedInstallationTypes;

		if (disAllowedInstallationTypes != null)
			this.disAllowedInstallationTypes = disAllowedInstallationTypes;

		this.defaultName = defaultName;
		this.resources = resources;
		this.settlementEquipmentNeeded = settlementEquipmentNeeded;
		this.allowsSettlements = allowsSettlements;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.aceitunaproject.server.terrain.TerrainType#getAllowedInstallationTypes
	 * ()
	 */
	@Override
	public List<InstallationType> getAllowedInstallationTypes() {

		return allowedInstallationTypes;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.aceitunaproject.server.terrain.TerrainType#getCombatEffects(com.
	 * aceitunaproject.server.equipment.Equipment)
	 */
	@Override
	public CombatEffects getCombatEffects(Equipment equipment) {

		return equipment.getCombatEffects(this);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.aceitunaproject.server.terrain.TerrainType#getCombatEffects(com.
	 * com.aceitunaproject.server.equipment.Equipment)
	 */
	@Override
	public CombatEffects getCombatEffects(Equipment equipmentA,
			Equipment equipmentB) {

		return equipmentA.getCombatEffects(this, equipmentB);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.aceitunaproject.server.terrain.TerrainType#getDefaultName()
	 */
	@Override
	public String getDefaultName() {

		return defaultName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.aceitunaproject.server.terrain.TerrainType#getMovementEffects(com
	 * .aceitunaproject.server.equipment.Equipment)
	 */
	@Override
	public MovementEffects getMovementEffects(Equipment equipment) {

		return equipment.getMovementEffects(this);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.aceitunaproject.server.terrain.TerrainType#getResources()
	 */
	@Override
	public List<GoodProduction> getResources() {
		if(resources == null)
		{
			resources = new LinkedList<GoodProduction>();
		}
		return resources;
	}

	@Override
	public List<InstallationType> getDisAllowedInstallationTypes() {

		return disAllowedInstallationTypes;
	}

	@Override
	public boolean allowsSettlements() {

		return this.allowsSettlements;
	}

	@Override
	public List<Equipment> getSettlementEquipmentNeeded() {

		return this.settlementEquipmentNeeded;
	}

}
